package com.aspose.cells;

import java.util.HashMap;
import java.util.Iterator;

public class Row {
   zp a;
   zf b;
   RowCollection c;
   Cells d;

   Row(Cells cells, RowCollection rows, zp rowData, boolean cacheCell) {
      this.d = cells;
      this.c = rows;
      this.a = rowData;
      if (cells.getMultiThreadReading()) {
         this.b = new zsc(this);
      } else if (cacheCell) {
         this.b = new zbua(5, this);
      } else {
         this.b = new zbmp(this);
      }

   }

   int a() {
      return this.a.a();
   }

   Cell a(int var1) {
      return this.b.a(var1);
   }

   void b() {
      if (this.a.f() < 0) {
         throw new CellsException(7, "Row has been removed: " + this.a.h());
      }
   }

   void a(int var1, int var2) {
      this.b(this.a.c(var1), var2);
   }

   void b(int var1, int var2) {
      this.k().getWorkbook().b();
      this.a.c(var1, var2);
      this.b.a();
      this.d.n();
   }

   void c() {
      this.k().getWorkbook().b();
      this.d.n();
      this.b.a();
      this.a.e(-1);
   }

   /** @deprecated */
   public Cell getCellByIndex(int index) {
      this.b();
      return this.a(this.a.c(index));
   }

   Cell b(int var1) {
      zfv var2 = new zfv();
      var2.a = (short)var1;
      int var3 = this.a.a(-1, var2);
      if (var1 > this.d.getMaxColumn()) {
         this.d.a((short)var1);
      }

      return new Cell(this, var3);
   }

   public boolean isBlank() {
      this.b();
      if (this.a.a() == 0) {
         return true;
      } else {
         zgo var1 = new zgo();
         zahl var2 = this.a.b();

         int var3;
         do {
            var3 = var2.a();
            if (var3 < 0) {
               return true;
            }
         } while(!var1.a(this.a, var3));

         return false;
      }
   }

   public Cell get(int column) {
      this.b();
      return this.a(column, false, true);
   }

   public Iterator iterator() {
      this.b();
      return new zsm(this);
   }

   Cell c(int var1) {
      return this.a(var1, false, true);
   }

   int d(int var1) {
      return this.b.d(var1);
   }

   Cell a(int var1, boolean var2, boolean var3) {
      return this.b.a(var1, var2, var3);
   }

   Cell a(RowCollection var1, int var2, int var3, boolean var4, boolean var5) {
      Cell var6 = this.b.b(var2, false, var5);
      if (var4) {
         var1.a(var6, this);
      }

      return var6;
   }

   Cell a(RowCollection var1, int var2, boolean var3, boolean var4, boolean var5) {
      Cell var6 = this.a(var2, var3, var5);
      if (var4 && var6 != null && var6.c.b == -1) {
         var1.a(var6, this);
      }

      return var6;
   }

   public Cell getCellOrNull(int column) {
      return this.a(column, true, false);
   }

   int d() {
      return e(this.a);
   }

   void e(int var1) {
      a(this.a, var1);
   }

   int e() {
      return this.a.j();
   }

   void f(int var1) {
      b(this.a, var1 & '\uffff');
   }

   void a(boolean var1) {
      this.a.a(0, zbbj.a(this.a.l(0), var1));
   }

   public double getHeight() {
      return f(this.a);
   }

   public void setHeight(double value) {
      a(this.d, this.a, value);
   }

   public boolean isHidden() {
      return zbbj.c(this.a.l(0));
   }

   public void setHidden(boolean value) {
      this.a.a(0, zbbj.b(this.a.l(0), value));
   }

   void b(boolean var1) {
      this.a(var1);
   }

   double f() {
      return (double)(this.e() & '\uffff') / 20.0D;
   }

   boolean g() {
      return zbbj.e(this.a.l(0));
   }

   void c(boolean var1) {
      this.a.a(0, zbbj.d(this.a.l(0), var1));
   }

   public int getIndex() {
      return this.a.h();
   }

   byte h() {
      return (byte)zbbj.f(this.a.l(0));
   }

   void a(byte var1) {
      this.a.a(0, zbbj.a(this.a.l(0), var1 & 255));
   }

   public byte getGroupLevel() {
      return this.h();
   }

   public boolean isHeightMatched() {
      return zbbj.d(this.a.l(0));
   }

   public void setHeightMatched(boolean value) {
      this.a.a(0, zbbj.c(this.a.l(0), value));
   }

   public Style getStyle() {
      new Style(this.k().c());
      return a(this.d, this.a);
   }

   void a(Style var1) {
      this.c(true);
      this.e(this.k().c().a(var1));
   }

   Style i() {
      return b(this.d, this.a);
   }

   boolean j() {
      return d(this.a);
   }

   void a(Row var1) {
      zbbj var2 = new zbbj();
      zbbj var3 = var1.a.a(var2, 15);
      if (var3 != var2) {
         var2.a(var3);
      }

      if (var1.j() && this.k().c() != var1.k().c()) {
         var2.d = this.k().c().a(var1.i());
      } else {
         var2.d = var1.a.i();
      }

      this.a.b(var2, 13);
   }

   Worksheet k() {
      return this.d.h();
   }

   void a(Row var1, CopyOptions var2) {
      zbbj var3 = new zbbj();
      zbbj var4 = var1.a.a(var3, 15);
      if (var4 != var3) {
         var3.a(var4);
      }

      if (var1.j()) {
         if (!var2.a && this.k().c() != var1.k().c()) {
            if (var2.b.get(var1.d()) != null) {
               var3.d = (Integer)var2.b.get(var1.d());
            } else {
               int var5 = var1.d();
               Style var6 = var1.i();
               if (var6 == null) {
                  var3.d = 15;
               } else {
                  var3.d = this.k().c().a(var6);
               }

               var2.b.put(var5, var3.d);
            }
         } else {
            var3.d = var1.d();
         }
      }

      this.a.b(var3, 13);
   }

   public Cell getFirstCell() {
      this.b();
      return this.a() == 0 ? null : new Cell(this, this.a.a(-1, false));
   }

   public Cell getLastCell() {
      this.b();
      return this.a() == 0 ? null : new Cell(this, this.a.a(-1, true));
   }

   public Cell getLastDataCell() {
      this.b();
      if (this.a() == 0) {
         return null;
      } else {
         zgo var1 = new zgo();
         zahl var2 = this.a.a(-1, -1, true);

         int var3;
         do {
            var3 = var2.a();
            if (var3 < 0) {
               return null;
            }
         } while(!var1.a(this.a, var3));

         return new Cell(this, var3);
      }
   }

   public void applyStyle(Style style, StyleFlag flag) {
      this.b();
      Cells var3 = this.d;
      ColumnCollection var4 = var3.getColumns();
      zahl var5 = this.a.b();
      int var6;
      if (!flag.getAll()) {
         HashMap var14 = new HashMap();
         boolean var8 = false;
         Style var9 = null;

         while(true) {
            var6 = var5.a();
            int var10;
            int var15;
            if (var6 < 0) {
               var10 = this.d();

               for(int var11 = 0; var11 < var4.getCount(); ++var11) {
                  Column var12 = var4.getColumnByIndex(var11);
                  if (var12.e()) {
                     var6 = this.a.b(var12.getIndex());
                     if (var6 < 0) {
                        zfv var13 = new zfv();
                        var13.a = (short)var12.getIndex();
                        var15 = var10 == 15 ? var12.c() : var10;
                        if (var14.get(var15) != null) {
                           var13.b = (Integer)var14.get(var15);
                        } else {
                           var9 = new Style(this.d.r());
                           var9.copy(var3.r().B().a(var15));
                           zakq.a(style, var9, flag);
                           var13.b = var3.r().B().c(var9);
                           var14.put(var15, var13.b);
                        }

                        this.a.a(-var6 - 1, var13);
                     }
                  }
               }

               var9 = this.getStyle();
               zakq.a(style, var9, flag);
               this.a(var9);
               return;
            }

            var15 = Cell.a(var3, this.a, var6);
            if (var14.get(var15) != null) {
               this.a.j(var6, (Integer)var14.get(var15));
            } else {
               var9 = new Style(this.d.r());
               var9.copy(var3.r().B().a(var15));
               zakq.a(style, var9, flag);
               var10 = var3.r().B().c(var9);
               this.a.j(var6, var10);
               var14.put(var15, var10);
            }
         }
      } else {
         this.a(style);
         int var7 = this.d();

         while(true) {
            var6 = var5.a();
            if (var6 < 0) {
               return;
            }

            this.a.j(var6, var7);
         }
      }
   }

   boolean b(Row var1) {
      if (var1 == null) {
         return !this.j();
      } else {
         return this.i().equals(var1.i());
      }
   }

   public boolean equals(Object obj) {
      if (obj == this) {
         return true;
      } else {
         return !(obj instanceof Row) ? false : this.equals((Row)obj);
      }
   }

   public boolean equals(Row row) {
      return row == this || this.d == row.d && (this.a == row.a || this.a.h() == row.a.h());
   }

   static boolean a(zp var0) {
      return zbbj.c(var0.l(0));
   }

   static void a(zp var0, boolean var1) {
      var0.a(0, zbbj.b(var0.l(0), var1));
   }

   static void b(zp var0, boolean var1) {
      var0.a(0, zbbj.c(var0.l(0), var1));
   }

   static boolean b(zp var0) {
      return zbbj.e(var0.l(0));
   }

   static void c(zp var0, boolean var1) {
      var0.a(0, zbbj.d(var0.l(0), var1));
   }

   static byte c(zp var0) {
      return (byte)(var0.l(0) & 255 & 15);
   }

   static boolean d(zp var0) {
      return b(var0) && var0.i() != 15;
   }

   static int e(zp var0) {
      return !b(var0) ? 15 : var0.i();
   }

   static void a(zp var0, int var1) {
      if (var1 == -1) {
         var0.k(15);
      } else {
         var0.k(var1);
         if (var1 != 15 && !b(var0)) {
            c(var0, var1 != 15);
         }
      }

   }

   static void a(Cells var0, zp var1, boolean var2) {
      a(var1, var2);
      if (!var2 && var1.j() == 0) {
         var1.m((int)var0.a());
      }

   }

   static Style a(Cells var0, zp var1) {
      Style var2 = new Style(var0.h().c());
      if (!b(var1)) {
         var2.copy(var0.h().c().D());
      } else {
         int var3 = var1.i();
         if (var3 < var0.h().c().B().getCount()) {
            var2.a(var0.h().c(), var3);
         } else {
            var2.copy(var0.h().c().D());
         }
      }

      return var2;
   }

   static Style b(Cells var0, zp var1) {
      if (!b(var1)) {
         return var0.h().c().D();
      } else {
         int var2 = var1.i();
         return var2 < var0.h().c().B().getCount() ? var0.h().c().B().a(var2) : var0.h().c().D();
      }
   }

   static void b(zp var0, int var1) {
      if (var1 > 0) {
         zbbj var2 = var0.a(new zbbj(), 5);
         var2.b(false);
         var2.e = (short)var1;
         var0.b(var2, 5);
      } else {
         a(var0, true);
      }

   }

   static double a(zr var0, int var1) {
      return (double)var0.g(var1) / 20.0D;
   }

   static double f(zp var0) {
      zbbj var1 = var0.a(new zbbj(), 5);
      return var1.b() ? 0.0D : (double)var1.e / 20.0D;
   }

   static int b(zr var0, int var1) {
      zbbj var2 = var0.b(var1, new zbbj(), 5);
      return var2.b() ? 0 : var2.e;
   }

   static void a(Cells var0, zp var1, double var2) {
      zbbj var4 = var1.a(new zbbj(), 5);
      if (var2 <= 0.0D) {
         var4.b(true);
         var4.e = 0;
      } else {
         var4.e = (short)((int)(var2 * 20.0D + 0.5D));
      }

      var4.c(false);
      var1.b(var4, 5);
   }
}
